<template>
  <div>
    <el-form :model="detailObj"  ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
            <el-form-item label="任务单号" prop="taskNo">
              <el-input v-model="detailObj.planTaskTotal.taskNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="任务流水号" prop="taskSerialNo" v-if="type!=='insert'">
              <el-input v-model="detailObj.planTaskTotal.taskSerialNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="生产令号" prop="makeNo">
              <el-input v-model="detailObj.planTaskTotal.makeNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="图纸序号" prop="drawNo">
              <el-input v-model="detailObj.planTaskTotal.drawNo" class="width220" :disabled="editDisalbe"></el-input>
            </el-form-item>
            <el-form-item label="29所编码" prop="code"  v-if="type!=='insert'">
              <el-input v-model="detailObj.planTaskTotal.code29" class="width220" disabled></el-input>
            </el-form-item>
            <!-- <el-form-item label="优先级" prop="priority">
               <el-input v-model="detailObj.planTaskTotal.priority" class="width220" disabled></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="计划属性" prop="planAttribute">
              <el-input v-model="detailObj.planAttribute" class="width220" disabled ></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="月度计划" prop="monthPlan">
              <el-input v-model="detailObj.monthPlan" class="width220" disabled></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="计划下发时间" prop="issueDate">
              <el-date-picker v-model="detailObj.issueDate" type="datetime" placeholder="计划下发时间" class="width220 noMargin" disabled></el-date-picker>
            </el-form-item> -->
            <el-form-item label="外包计划完成时间" prop="wbPlanFinsihDate">
              <el-date-picker v-model="detailObj.planTaskTotal.wbPlanFinsihDate" type="datetime"  placeholder="外包完成时间" class="width220 noMargin" :disabled="editDisalbe"></el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="计划完成时间" prop="planFinsihDate">
              <el-date-picker v-model="detailObj.planFinsihDate" type="datetime" placeholder="计划完成时间" class="width220 noMargin" :disabled="editDisalbe"></el-date-picker>
            </el-form-item> -->
            <el-form-item label="件数" prop="nums">
              <el-input v-model="detailObj.planTaskTotal.nums" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item>
            <el-form-item label="图纸编号" prop="drawCode">
              <el-input v-model="detailObj.planTaskTotal.drawCode" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="图纸名称" prop="drawName">
              <el-input v-model="detailObj.planTaskTotal.drawName" class="width220" disabled ></el-input>
            </el-form-item>
             <el-form-item label="项目图纸张数" prop="drawNums">
              <el-input v-model="detailObj.planTaskTotal.nums" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item>
            <!-- <el-form-item label="批次号" prop="batch">
              <el-input v-model="detailObj.batch" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="自带原料" prop="isHasMaterial">
              <el-select v-model="detailObj.isHasMaterial" placeholder="请选择是否自带原料" class="width220" disabled>
                <el-option label="自备原料" :value="1"></el-option>
                <el-option label="需要采购" :value="0"></el-option>
              </el-select>
            </el-form-item> -->
            <!-- <el-form-item label="客户" prop="customerName"  v-if="type==='insert'">
               <el-autocomplete  class="width220" v-model="detailObj.planTaskTotal.customerName.name" :fetch-suggestions="querySearchAsync" placeholder="请输入供应商名称" @select="handleSelect" :disabled="editDisalbe"></el-autocomplete>
            </el-form-item> -->
            <!-- <el-form-item label="物料到达时间" prop="materialArriveTime" v-if="type==='update'">
              <el-input v-model="detailObj.materialArriveTime" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料到达确认人" prop="materialArrivePersonName" v-if="type==='update'">
              <el-input v-model="detailObj.materialArrivePersonName" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料下料时间" prop="materialTailorTime" v-if="type==='update'">
              <el-input v-model="detailObj.materialTailorTime" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料下料人" prop="materialTailorPersonName" v-if="type==='update'">
              <el-input v-model="detailObj.materialTailorPersonName" disabled class="width220" ></el-input>
            </el-form-item> -->
            <el-form-item label="外协时间" prop="remark" >
              <el-date-picker v-model="detailObj.wxTime" type="datetime" :disabled="detailObj.status==1"  placeholder="外协时间" class="width220 noMargin" ></el-date-picker>

            </el-form-item>

            <el-form-item label="外协人员" prop="remark">
                <el-select v-model="detailObj.wxUser" filterable clearable placeholder="请选择" :disabled="detailObj.status==1"  >
                  <el-option
                    v-for="item in workerList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                  </el-option>
                </el-select> 
            </el-form-item>

            
            <el-form-item label="计划交货日期" prop="remark" >
              <el-date-picker v-model="detailObj.planDeliveryDate" type="date" :disabled="detailObj.status==1"   placeholder="外协时间" class="width220 noMargin" ></el-date-picker>
            </el-form-item>

            
            <el-form-item label="实际交货日期" prop="remark">
              <el-date-picker v-model="detailObj.realDeliveryDate" type="date" :disabled="detailObj.status==1"  placeholder="外协时间" class="width220 noMargin"></el-date-picker>
            </el-form-item>

            
            <el-form-item label="外协厂家" prop="remark" >
              <el-input v-model="detailObj.wxProducer"  class="width220" :disabled="detailObj.status==1"  ></el-input>
            </el-form-item>

            
            <el-form-item label="合格数量" prop="remark" >
              <el-input v-model="detailObj.qualifiedNums"  class="width220" :disabled="detailObj.status==1"  ></el-input>
            </el-form-item>

            
            <el-form-item label="不合格数量" prop="unqualifiedNums">
              <el-input v-model="detailObj.unqualifiedNums"  class="width220" :disabled="detailObj.status==1"  ></el-input>
            </el-form-item>


            
            <el-form-item label="创建时间" prop="unqualifiedNums" >
              <el-date-picker v-model="detailObj.createTime" type="datetime"  placeholder="外协时间" class="width220 noMargin" :disabled="detailObj.status==1" ></el-date-picker>
            </el-form-item>


            
            <el-form-item label="外协创建人" prop="unqualifiedNums" >
              <el-input v-model="detailObj.createUserName"  class="width220" :disabled="detailObj.status==1"  ></el-input>
            </el-form-item>



            <el-form-item label="备注" prop="remark" >
              <el-input v-model="detailObj.remark"  class="width220" type="textarea" :disabled="detailObj.status==1" ></el-input>
            </el-form-item>
            <!-- <el-form-item label="导入人" prop="importerName" v-if="type==='update'">
              <el-input v-model="detailObj.importerName" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="导入时间" prop="importDate" v-if="type==='update'">
              <el-input v-model="detailObj.importDate" disabled class="width220" ></el-input>
            </el-form-item> -->
            <el-form-item  class="form-item-block text-center" style="margin-top:15px;" v-if="detailObj.status==0" >
              <el-button type="primary" @click="onSubmit()">外协完成</el-button>
            </el-form-item>
          </el-form>
  </div>
</template>
<script>
import planApi from 'plugins/axios/planApi.js';
import purchaseApi from 'plugins/axios/purchaseApi.js';
import salesApi from 'plugins/axios/salesApi.js';
export default {
  name: 'taskDetail29',
  props:{
    detailObj:{
      type:Object
    },
    type:{
      type:String
    },
    editDisalbe:{
      type:Boolean
    }
  },
  data (){
    return {
      workerList:[],
    }
  },
  watch:{
    
  },
  created(){
    this.queryWorkerList();
  },
  methods:{
    onSubmit(){
      let self = this;
      
      // self.detailObj.issueDate = self.detailObj.issueDate? self.timestampToTime( self.detailObj.issueDate):null;
      // self.detailObj.wbPlanFinsihDate = self.detailObj.wbPlanFinsihDate? self.timestampToTime( self.detailObj.wbPlanFinsihDate):null;
      // self.detailObj.planFinsihDate =  self.detailObj.planFinsihDate?self.timestampToTime( self.detailObj.planFinsihDate):null;

      // let postData=JSON.parse(JSON.stringify(self.detailObj));
      // delete postData.customerName;
      self.detailObj.status = 1;
      planApi.updateMpWx(self.detailObj).then(res=>{
        self.$emit('editSuccess');
         this.$message({
          message: '修改成功',
          type: 'success'
        });
      })
    },
    queryWorkerList(){
      let self = this;
      planApi.getWorkerList().then(res=>{
        self.workerList = res.content;
      });
    },
    querySearchAsync(queryString, callback){
      salesApi.customerInfoListByName({keyWord:queryString?queryString:''}).then(res=>{
        res.content.forEach(item=>{
          item.value = item.name;
        })
         callback(res.content);
      })
    },
    handleSelect(item){
      this.detailObj.customer = item.id;
    }
  }
}
</script>
<style lang="stylus" scoped>

</style>